﻿#ifndef EXPEDITDLG_H
#define EXPEDITDLG_H
#include "TABLEDEFINE.h"
#include "DbCfgFun.h"
#include "GetColumnInfo.h"
#include <QDialog>
namespace Ui {
    class ExpEditDlg;
}

class ExpEditDlg : public QDialog 
{
    Q_OBJECT
public:
    ExpEditDlg(unsigned int CurRecordId, QWidget *parent = 0);
    ~ExpEditDlg();

	
	void	vdSetFormulaStruct();
	void	vdGetFormulaStruct(rExpDefine_Info &exp_define);
protected:
	void	InitDlgShow();
	void	InitVarListShow();
    void    InitIoTree();
	//获取二次计算输入量
	void	GetExpVarList();
	void	DeleteVarFromDB(int parentid);
	void	ReleasColumnInfo();
	
	int		SaveData();
	bool    isexist(IOTreeTypeS data);
	int     InsertExpRecord(int m_expid);
	int     InsertExpVariableLst(unsigned int ExpId);
    bool    check_exp_validty(rExpDefine_Info  *exp);
	int     rExpChk(char *pStr,char *pExp);
	void    refreshInputlist();
protected:
    void changeEvent(QEvent *e);
	void Explain_Text();

protected slots:
	void    uitem_click(QTreeWidgetItem * item, int column);
	void    item_doubleclick(QTreeWidgetItem * item, int column);
	void	AddBtn();
	void	DelOneBtn();
	void	DelAllBtn();
	void	CompileBtn();
	void    AutoAllOrExp();    //自动全或表达式
	void    AutoAllANDexp();   //自动全与表达式
	void	AffirmBtn();
	void    InsertBtn();
	void	ExpType_slot();
	void	Explain_Btn();
    void    expout_link();
	void    InitRecdlg();
	void	CompileExp();
signals:
	void	RefreshData_Signal();

private:
    Ui::ExpEditDlg *ui;
	unsigned int		m_CurRecordId;
	int					m_TranslateResult;
	rExpDefine_Info		m_ExpDefine;
	char				m_newExpType;
	int					m_columnNum;
	int					m_RecordLength;
	cColumn_Info		*m_pColumnInfo;
	int					*m_pDataOffset;
	IOTreeTypeS         expout_data;         //表达式输出点
	QTreeWidgetItem *   Item_Root;
	QList<QTreeWidgetItem *> items;
	GetColumnInfo	    m_ColInfo;
	rExpDefine_Info     m_pre_exp;
	int  m_ParentId;
	int  m_exp_varnum;
};

#endif // EXPEDITDLG_H
